package algo.math.evaluator.expression;

import java.util.List;
import java.util.Map;
import algo.math.evaluator.base.IBase;
import algo.math.evaluator.tokenizer.interfaces.*;


/**
 * Represent an arithmetic expression
 */
public class Expression {

	private List<IToken> _tokens;
	
	private Map<String, Object> _variables;
	
	private IBase _base;


	public Expression(List<IToken> tokens,Map<String, Object> variables, IBase base)
	{
		_tokens = tokens;
		_variables = variables;
		_base = base;
	}
	
	/**
	 * Gets the expression's tokens.
	 *
	 * @return the tokens
	 */
	public List<IToken> getTokens ()
	{
		return _tokens;
	}
	
	/**
	 * Gets the number base associated to the arithmetic Expression.
	 *
	 */
	public IBase getBase ()
	{
		return _base;
	}
	
	/**
	 * Gets the variables mapped to the arithmetic Expression.
	 *
	 */
	public  Map<String, Object> getVariables()
	{
		return _variables;
	}
	
    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString()
    {
    	String r="";
    	for (IToken token : _tokens) {
			r+= token.getValue() + " ";
		}
    	return r;
    }
}
